import { ref, computed } from 'vue'
import { defineStore } from 'pinia'

export const useCollapseStore = defineStore('collapse', () => {
  // state
  const collapse = ref(false)  // 默认情况下，左侧边栏的打开、非折叠状态。

  // getter
  const isCollapsed = computed(() => collapse.value)
  const isExpanded = computed(() => !collapse.value)

  // action
  function switchCollapse() {
    collapse.value = !collapse.value
  }

  return {
    collapse,
    isCollapsed, isExpanded,
    switchCollapse
  }
})
